﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class User_UC2Password : System.Web.UI.Page
{
    private clsUserAccount ua = clsUserAccount.getCookieUser(true);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            bindData();
    }

    private void bindData()
    {
        tbxName.Text = ua.UserName;
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string nowPwd = tbxNowPassowrd.Text;
        string newPwd = tbxNewPassowrd.Text;

        if (nowPwd==ua.UserPass)
        {
            clsUserAccount.ChangePassword(ua.UserName, newPwd);
            lbMsg.Text = "<font color=blue>新的密码已修改成功！</font>";
            Utils.WrAlertGo("新的密码已修改成功。\\n\\n请重新登陆,以使修改的新密码生效！", "../Login.aspx");
        }
        else
        {
            lbMsg.Text = "<font color=red>修改密码失败，请确认您填入的当前密码是否正确！</font>";
            ClientScript.RegisterClientScriptBlock(this.GetType(), "msg", "alert('修改密码失败，请确认您填入的当前密码是否正确！');", true);
            //Utils.WrAlert("修改密码失败，请确认您填入的当前密码是否正确！");
        }

    }

    protected void Page_PreInit(object sender, EventArgs e)
    {
        if (ua.MemberType==1)
            Page.MasterPageFile = "~/User/UC1.master";
    }
}